#ifndef _ROSTERENTRY_H_
#define _ROSTERENTRY_H_

#include <string>

#include <packet/RosterPacket.h>

class XMPPConnection;
class RosterGroup;

/**
 * Each user in your roster is represented by a roster entry, which contains the user's
 * JID and a name or nickname you assign.
 *
 * @author Matt Tucker
 */
class RosterEntry {
public:

    /**
     * Creates a new roster entry.
     *
     * @param user the user.
     * @param name the nickname for the entry.
     * @param type the subscription type.
     * @param status the subscription status (related to subscriptions pending to be approbed).
     * @param connection a connection to the XMPP server.
     */
    RosterEntry(std::string & user, std::string & name, RosterPacket::ITEM_TYPE type,
                RosterPacket::ItemStatus * status, XMPPConnection * connection) ;

    /**
     * Returns the JID of the user associated with this entry.
     *
     * @return the user associated with this entry.
     */
	const std::string getUser() const{
        return user;
    }
	
    /**
     * Returns the name associated with this entry.
     *
     * @return the name.
     */
	std::string getName() {
        return name;
    }
	
    /**
     * Sets the name associated with this entry.
     *
     * @param name the name.
     */
    void setName(std::string & name) ;
	
    /**
     * Updates the state of the entry with the new values.
     *
     * @param name the nickname for the entry.
     * @param type the subscription type.
     * @param status the subscription status (related to subscriptions pending to be approbed).
     */
    void updateState(std::string & name, RosterPacket::ITEM_TYPE type, RosterPacket::ItemStatus * status); 
	
    /**
     * Returns an unmodifiable collection of the roster groups that this entry belongs to.
     *
     * @return an iterator for the groups this entry belongs to.
     */
	std::list<RosterGroup*> getGroups() ;
	
    /**
     * Returns the roster subscription type of the entry. When the type is
     * RosterPacket.ItemType.none or RosterPacket.ItemType.from,
     * refer to {@link RosterEntry getStatus()} to see if a subscription request
     * is pending.
     *
     * @return the type.
     */
	RosterPacket::ITEM_TYPE getType() {
        return type;
    }
	
    /**
     * Returns the roster subscription status of the entry. When the status is
     * RosterPacket.ItemStatus.SUBSCRIPTION_PENDING, the contact has to answer the
     * subscription request.
     *
     * @return the status.
     */
	RosterPacket::ItemStatus * getStatus() {
        return status;
    }
	
	std::string toString() ;
	
	bool equals(/*Object object*/) ;
	
	static RosterPacket::Item * toRosterItem( RosterEntry * entry) ;
private:
	std::string user;
	std::string name;
	RosterPacket::ITEM_TYPE type;
	RosterPacket::ItemStatus * status;
    XMPPConnection * connection;

};

inline bool operator==(const RosterEntry& lhs, const RosterEntry& rhs) {
	return lhs.getUser() == rhs.getUser();
}
#endif // -- _ROSTERENTRY_H_
